import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:largefriends/res/lf_fonts.dart';
import 'package:largefriends/res/lf_text_style.dart';

import '../res/lf_color.dart';

AppBar lfAppBar<T>({
  Function()? leadingCallback,
  T? title,
  Widget? leadingIcon,
  List<Widget>? actions,
  double? height,
  bool? centerTitle,
  Color? background,
}) {
  return AppBar(
    toolbarHeight: height,
    backgroundColor: background,
    leading: leadingCallback != null
        ? InkWell(
            child: Padding(
              padding: EdgeInsets.all(8.r),
              child: leadingIcon ??
                  Icon(
                    Icons.arrow_back,
                    color: colorFF007F,
                  ),
            ),
            onTap: () {
              leadingCallback.call();
            },
          )
        : null,
    automaticallyImplyLeading: false,
    centerTitle: centerTitle ?? false,
    titleSpacing: 1.w,
    title: title is String
        ? ShaderMask(
            shaderCallback: (Rect bounds) {
              return LinearGradient(
                begin: const Alignment(-0.5, -0.9),
                end: const Alignment(0.5, 0.9),
                colors: [colorFF007F, colorFF007F, colorBF00FF, colorBF00FF],
              ).createShader(Offset.zero & bounds.size);
            },
            blendMode: BlendMode.srcATop,
            child: Text(
              title,
              style: lfTextStyle(
                  sp: 20.sp, fontFamily: fontBold, color: color210215),
            ))
        : title is Widget
            ? title
            : null,
    actions: actions,
  );
}
